import fs from "fs"
import globals from "globals"
import pluginJs from "@eslint/js"
import tseslint from "typescript-eslint"
import pluginVue from "eslint-plugin-vue"
import eslintConfigPrettier from "eslint-config-prettier"
import vueParser from "vue-eslint-parser"

const data = fs.readFileSync("./examples/.eslintrc-auto-import.json", "utf8")
const autoImport = JSON.parse(data)

export default tseslint.config(
  pluginJs.configs.recommended,
  ...tseslint.configs.recommended,
  ...pluginVue.configs["flat/essential"],
  eslintConfigPrettier,
  {
    languageOptions: {
      parser: vueParser,
      parserOptions: {
        parser: tseslint.parser,
        sourceType: "module",
      },
      globals: { ...globals.browser, ...globals.node, ...autoImport.globals },
    },
    ignores: ["dist/*"],
    rules: {
      "vue/multi-word-component-names": "off",
      "@typescript-eslint/no-explicit-any": "off",
    },
  },
)
